package com.itheima.health.controller;

import com.itheima.health.common.R;
import com.itheima.health.model.pojos.BusinessReportDataVo;
import com.itheima.health.model.pojos.MemberReportVo;
import com.itheima.health.model.pojos.SetmealReportVo;
import com.itheima.health.service.MemberReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/report")
public class MemberReportController {
    @Autowired
    private MemberReportService memberReportService;
    private BusinessReportDataVo businessReportDataVo;

    /**
     * 会员数据统计
     * @return
     */
    @GetMapping("/getMemberReport")
    public R getMemberReport(){
        MemberReportVo memberReportVo = memberReportService.getMemberReport();
        R r = new R();
        r.setData(memberReportVo);
        r.setFlag(true);
        return  r;
    }

    /**
     * 预约套餐占比统计
     * @return
     */
    @GetMapping("/getSetmealReport")
    public R getSetmealReport(){
        SetmealReportVo setmealReportvo = memberReportService.getSetmealReport();
        R r = new R();
        r.setData(setmealReportvo);
        r.setFlag(true);
        return  r;
    }
    /**
     * 运营数据统计
     */
    @GetMapping("/getBusinessReportData")
    public R getBusinessReportData(){
         businessReportDataVo=memberReportService.getBusinessReportData();

        R r = new R();
        r.setData(businessReportDataVo);
        r.setFlag(true);
        return  r;
    }
    /**
     * 到处excel表
     */
    @GetMapping("/exportBusinessReport")
    public R exportBusinessReport(HttpServletResponse response, String fileName){

        memberReportService.exportBusinessReport(response,fileName,businessReportDataVo);
        R r = new R();
        r.setFlag(true);
        return  r;
    }
}
